#!/usr/bin/perl

if(@ARGV != 3) {
  print "Usage: shift.pl problem input sw|ne|se|nw\n";
  die;
}
my $eps;
open FILE, $ARGV[0];
while(<FILE>) {
  if(/eps(.*):(.*)/) {
    $eps = $2;
  }
}
close FILE;
my @sft;
if($ARGV[2] eq  "sw") {
  $sft[0] = -$eps;
  $sft[1] = -$eps;
} elsif ($ARGV[2] eq  "ne") {
  $sft[0] = $eps;
  $sft[1] = $eps;
} elsif ($ARGV[2] eq  "se") {
  $sft[0] = $eps;
  $sft[1] = -$eps;
} elsif ($ARGV[2] eq  "nw") {
  $sft[0] = -$eps;
  $sft[1] = $eps;
}


open FILE, $ARGV[1];
while(<FILE>) {
 my @a = split (' ', $_);
 my $i = 0;
 for $x (@a) {
    print $x + $sft[$i], ' ';
    $i ++;
 }
 print "\n";
}
close FILE;